package thread;

public class Husband extends Thread {
    private Accout ac;
    public Husband(String name,Accout ac){
        super(name);
        this.ac=ac;
    }

    @Override
    public void run() {
        while(true){

                try {
                    sleep(20000);
                    ac.deposit(3000);
                    System.out.println(super.getName()+"存钱"+3000+"元,现在余额是"+ac.getMoney());

                    synchronized (ac) {
                        ac.notifyAll();
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

        }
    }
}
